<!--
 * @Description: 原子组件-状态指示器
-->
<template>
  <span class="my-state" :class="[{ 'my-status-processing': pulse }, 'my-state-bg--' + type]"></span>
</template>

<script lang="ts" setup name="MyStatusIndicator">
const props = defineProps({
  type: {
    type: String,
    default: 'primary'
  },
  pulse: {
    type: Boolean,
    default: false
  }
})
// 解构 props
const { type, pulse } = props
</script>

<style lang="scss" scoped>
.my-state {
  display: inline-block;
  background: #000;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  vertical-align: middle;
}
.my-status-processing {
  position: relative;
  &:after {
    position: absolute;
    top: 0px;
    left: 0px;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: inherit;
    content: '';
    animation: warn 1.2s ease-in-out infinite;
  }
}
.my-state-bg--primary {
  background: var(--el-color-primary);
}
.my-state-bg--success {
  background: var(--el-color-success);
}
.my-state-bg--warning {
  background: var(--el-color-warning);
}
.my-state-bg--danger {
  background: var(--el-color-danger);
}
.my-state-bg--info {
  background: var(--el-color-info);
}

@keyframes warn {
  0% {
    transform: scale(0.5);
    opacity: 1;
  }
  30% {
    opacity: 0.7;
  }
  100% {
    transform: scale(2.5);
    opacity: 0;
  }
}
</style>
